<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
/*Route::get('user/{name}/{id}',function($id,$name){
    dd($id,$name);
});*/
//路由获取参数
/*Route::get('user/{name}/{id}',function(Request $request){
    dd($request::route('name')); //$request 对象 调用route 方法
                                    // $request::route->parameters() 获取所有参数
});*/


//路由参数的限制，利用正则表达式限制参数的类型
/*Route::get('user/{name}/{id}',function($name){
    return '通过参数检测';
})->where('name','[A-Za-z]+');*/

/*
 * 多种形式的请求匹配
 */
//展示表单
/*Route::get('user/',function(){
    return '<form action="/login" method="post">
            '.csrf_field().'
            <input type="text" name="test" >
            <input type="hidden" name="_method" value="DELETE" >
            <input type="submit">
            </form>';
});*/

/*Route::delete('/login',function(Request $request){
    dd( session('_token') );
    dd( $request::all() );
    return '已经接受到post请求';
});*/
//匹配
Route::get('user/',function(){
    return '<form action="/login" method="post">
            '.csrf_field().'
            <input type="text" name="test" >
            <input type="submit">
            </form>';
});

Route::match(['post','get'],'/login',function(){
        return '匹配方式';
});

//访问控制器
/*Route::get('/store','Weidian\StoreController@store');*/

//  把相同路由分组 共享信息 (命名空间)
Route::group(['namespace'=>'Weidian'],function(){
    Route::get('/store','StoreController@store');
    Route::get('/index','StoreController@index');
    Route::get('/choose','StoreController@choose');
});
// 不同模块或应用可以放在不同的路由组下分配前缀
/*Route::group(['namespace'=>'Weidian','prefix'=>'wap'],function(){
    Route::get('/store',function(){
        return '我是wap下面的store';
    });
    Route::get('/index','StoreController@index');
    Route::get('/choose','StoreController@choose');
});*/
